<template>
    <div>
        <div id="mainS4" style="width: 100%;height:17.5rem;position: absolute;left: 0;top: -2.5rem;margin: auto;"></div>
    </div>
</template>
  
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import * as echarts from 'echarts';
import { RequestStatisticGetCarByProcess } from "@/api/path/index.js";

// 基于准备好的dom，初始化echarts实例
// 绘制图表
onMounted(() => {
    RequestStatisticGetCarByProcess().then((res: any) => {
        var chartDom = document.getElementById('mainS4');
        var myChart = echarts.init(chartDom);
        var option;

        option = {
            grid: {
                left: '3%',
                right: '3%',
                bottom: '4%',
                containLabel: true,
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    // Use axis to trigger tooltip
                    type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
                }
            },
            xAxis: {
                type: 'value'
            },
            yAxis: {
                type: 'category',
                data: res.resultObj.name
            },
            series: [
                {
                    name: 'Direct',
                    type: 'bar',
                    stack: 'total',
                    itemStyle: {
                        color: '#007fff'
                    },
                    label: {
                        show: true
                    },
                    emphasis: {
                        focus: 'series'
                    },
                    data: res.resultObj.nums
                }
            ]
        };

        option && myChart.setOption(option);
    })
})
</script>
<style lang="scss" scoped></style>